import ShellUtils
from socket import *
addr = ("0.0.0.0", 22222)
BUFFER_SIZE = 1024


file = ShellUtils.FilesClass()

file.show_dir()

seq = int(input("请输入序号:"))

file_byte = file.read_file_to_byte(seq)

tcp_server = socket(AF_INET, SOCK_STREAM)
tcp_server.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
tcp_server.bind(addr)
tcp_server.listen(10)
tcp_client_sock, remote_addr = tcp_server.accept()
print(remote_addr)
tcp_client_sock.sendall(file_byte)

# with open("./test.webp", "wb+") as f:
#     f.write(file_byte)


